// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi 
// Source File Name:   SWLB.java

package com.oa.flow;

import com.oa.database.*;
import com.oa.util.Format;
import java.io.PrintStream;
import java.sql.*;
import java.util.*;

// Referenced classes of package com.oa.flow:
//            SWLBInfor

public class SWLB
{

    private DataConn dataConn;
    private QueryData queryData;
    private InsertData insertData;
    private Format format;
    private ResultSet rs;
    private PreparedStatement pstmt;
    private String sTable;
    private String sField;
    private String sCond;
    private String sql;
    private int iErrorCode;
    private SWLBInfor sWLBInfor;
    private ArrayList arrayList;

    public SWLB()
    {
        dataConn = null;
        queryData = null;
        insertData = null;
        format = null;
        rs = null;
        pstmt = null;
        sTable = "";
        sField = "";
        sCond = "";
        sql = "";
        iErrorCode = 0;
        sWLBInfor = null;
        arrayList = new ArrayList();
    }

    public SWLB(DataConn dataConnection)
    {
        dataConn = null;
        queryData = null;
        insertData = null;
        format = null;
        rs = null;
        pstmt = null;
        sTable = "";
        sField = "";
        sCond = "";
        sql = "";
        iErrorCode = 0;
        sWLBInfor = null;
        arrayList = new ArrayList();
        dataConn = dataConnection;
        format = new Format();
    }

    public Collection getSWLBlist()
    {
        return arrayList;
    }

    public SWLBInfor getSWLBInfor(String SWLB)
        throws Exception
    {
        sWLBInfor = null;
        try
        {
            sql = " select id,SWLB,SWMC,DBDZ,LMID,XXIDMC from OA_GYLC_SWLB  where SWLB='" + SWLB + "'";
            pstmt = dataConn.getConnection().prepareStatement(sql);
            rs = pstmt.executeQuery();
            if(rs.next())
            {
                sWLBInfor = new SWLBInfor();
                sWLBInfor.setId(rs.getInt("id"));
                sWLBInfor.setSWLB(rs.getString("SWLB"));
                sWLBInfor.setSWMC(rs.getString("SWMC"));
                sWLBInfor.setDBDZ(rs.getString("DBDZ"));
                sWLBInfor.setLMID(rs.getInt("LMID"));
                sWLBInfor.setXXIDMC(rs.getString("XXIDMC"));
            }
            pstmt.close();
        }
        catch(Exception e)
        {
            throw e;
        }
        return sWLBInfor;
    }

    public Collection getSWLBlist(String strCond)
        throws Exception
    {
        try
        {
            sql = " select id,SWLB,SWMC,DBDZ,LMID,XXIDMC from OA_GYLC_SWLB  WHERE LMID IN ( select LMID from OA_LMB WHERE SCBJ=0 AND  (FLMID IN (SELECT LMID FROM OA_LMB WHERE SCBJ=0)))  AND " + strCond;
            pstmt = dataConn.getConnection().prepareStatement(sql);
            rs = pstmt.executeQuery();
            arrayList = new ArrayList();
            for(; rs.next(); arrayList.add(sWLBInfor))
            {
                sWLBInfor = new SWLBInfor();
                sWLBInfor.setId(rs.getInt("id"));
                sWLBInfor.setSWLB(rs.getString("SWLB"));
                sWLBInfor.setSWMC(rs.getString("SWMC"));
                sWLBInfor.setDBDZ(rs.getString("DBDZ"));
                sWLBInfor.setLMID(rs.getInt("LMID"));
                sWLBInfor.setXXIDMC(rs.getString("XXIDMC"));
            }

            pstmt.close();
        }
        catch(Exception e)
        {
            throw e;
        }
        return arrayList;
    }

    public String getTableName(String SWLB)
        throws Exception
    {
        String strTable = "";
        try
        {
            sql = " select top 1 XXBM FROM OA_GYLC_BL  WHERE SWLB='" + SWLB + "'";
            pstmt = dataConn.getConnection().prepareStatement(sql);
            rs = pstmt.executeQuery();
            arrayList = new ArrayList();
            if(rs.next())
                strTable = rs.getString("XXBM");
            pstmt.close();
        }
        catch(Exception e)
        {
            throw e;
        }
        return strTable;
    }

    public boolean deleteSWLB(String SWLB)
        throws Exception
    {
        sTable = "OA_GYLC_SWLB";
        sCond = "SWLB = '" + SWLB + "'";
        DeleteData deleteData = new DeleteData(dataConn);
        iErrorCode = deleteData.delete(sTable, sCond);
        if(iErrorCode != 0)
        {
            System.out.println(deleteData.getErrorMessage());
            return false;
        } else
        {
            return true;
        }
    }

    public boolean deleteBL(String SWLB)
        throws Exception
    {
        sTable = "OA_GYLC_BL";
        sCond = "SWLB='" + SWLB + "'";
        DeleteData deleteData = new DeleteData(dataConn);
        iErrorCode = deleteData.delete(sTable, sCond);
        if(iErrorCode != 0)
        {
            System.out.println(deleteData.getErrorMessage());
            return false;
        } else
        {
            return true;
        }
    }

    public static void main(String args[])
    {
        DataConn dataConn = new DataConn();
        SWLB SWLB1 = new SWLB(dataConn);
        SWLBInfor sWLBInfor = new SWLBInfor();
        try
        {
            for(Iterator iterator = SWLB1.getSWLBlist("1=1").iterator(); iterator.hasNext(); System.out.println(sWLBInfor.getSWMC()))
                sWLBInfor = (SWLBInfor)iterator.next();

            System.out.println("##############");
            for(Iterator iterator = SWLB1.getSWLBlist().iterator(); iterator.hasNext(); System.out.println(sWLBInfor.getSWMC()))
                sWLBInfor = (SWLBInfor)iterator.next();

        }
        catch(Exception e)
        {
            System.out.println(e);
        }
    }
}
